package ConwaysGameOfLife;


import javax.swing.JButton;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Bryan
 */
public class BrushSettings extends javax.swing.JInternalFrame {

    /**
     * Creates new form brushSettings
     */
    final private WorldControl mediator;
    
    public BrushSettings(WorldControl mediator){
        this.mediator = mediator;
        initComponents();
        brushSizeIndicator.setText(brushSizeSlider.getValue()+ " x " + brushSizeSlider.getValue() + " Cells" );
        
    }
    public BrushSettings() {
        this.mediator = null;
        initComponents();
      
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel6 = new javax.swing.JPanel();
        brushSizeLabel = new javax.swing.JLabel();
        brushSizeSlider = new javax.swing.JSlider();
        brushSettingsDefault = new javax.swing.JButton();
        brushColorButton = new javax.swing.JButton();
        brushSizeIndicator = new javax.swing.JLabel();
        brushColorLabel = new javax.swing.JLabel();

        setIconifiable(true);
        setPreferredSize(new java.awt.Dimension(160, 225));

        jPanel6.setPreferredSize(new java.awt.Dimension(160, 278));

        brushSizeLabel.setText("Brush Size");

        brushSizeSlider.setMaximum(500);
        brushSizeSlider.setMinimum(1);
        brushSizeSlider.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                brushSizeSliderStateChanged(evt);
            }
        });

        brushSettingsDefault.setText("Default Settings");
        brushSettingsDefault.setPreferredSize(new java.awt.Dimension(138, 25));
        brushSettingsDefault.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                brushSettingsDefaultActionPerformed(evt);
            }
        });

        brushColorButton.setBackground(new java.awt.Color(0, 102, 102));
        brushColorButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                brushColorButtonActionPerformed(evt);
            }
        });

        brushSizeIndicator.setText("# x # Cells");

        brushColorLabel.setText("Brush Color");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(brushSettingsDefault, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(brushSizeLabel)
                        .addComponent(brushSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(brushColorButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(brushSizeIndicator)
                    .addComponent(brushColorLabel))
                .addContainerGap(13, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(brushSizeLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(brushSizeIndicator)
                .addGap(1, 1, 1)
                .addComponent(brushSizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(brushColorLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(brushColorButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                .addComponent(brushSettingsDefault, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void brushColorButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_brushColorButtonActionPerformed
        mediator.toggleBrushPallete();
    }//GEN-LAST:event_brushColorButtonActionPerformed

    private void brushSettingsDefaultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_brushSettingsDefaultActionPerformed
        brushSizeSlider.setValue(mediator.getDefaultBrushSize());
        mediator.defaultBrushColors();
    }//GEN-LAST:event_brushSettingsDefaultActionPerformed

    private void brushSizeSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_brushSizeSliderStateChanged
        brushSizeIndicator.setText(brushSizeSlider.getValue()+ " x " + brushSizeSlider.getValue() + " Cells" );
    }//GEN-LAST:event_brushSizeSliderStateChanged

    public JButton getbrushColorButton(){
        return brushColorButton;
        
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton brushColorButton;
    private javax.swing.JLabel brushColorLabel;
    private javax.swing.JButton brushSettingsDefault;
    private javax.swing.JLabel brushSizeIndicator;
    private javax.swing.JLabel brushSizeLabel;
    private javax.swing.JSlider brushSizeSlider;
    private javax.swing.JPanel jPanel6;
    // End of variables declaration//GEN-END:variables
}
